package com.ysg.binding.viewadapter;

import android.widget.CheckBox;
import android.widget.CompoundButton;
import androidx.databinding.BindingAdapter;
import com.ysg.binding.command.BindingCommand;

public class CheckBoxViewAdapter {

    @BindingAdapter(value = {"onCheckedChangedCommand"}, requireAll = false)
    public static void setOnCheckedChangedCommand(final CheckBox checkBox, BindingCommand<Boolean> bindingCommand) {
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
                bindingCommand.execute(checked);
            }
        });
    }
}
